

<script setup lang="ts">
import { ref ,reactive} from 'vue'
import customNavigate  from './components/customNavigate.vue'
import customSwiper  from './components/customSwiper.vue'
import myswiper from './components/myswiper.vue'
import myselect from './components/myselect.vue'
import mydell from './components/mydell.vue'
import noticeBar from './components/noticeBar.vue'
import Pageskeleton from './components/Pageskeleton.vue'
import { getHomeBannerAPI } from '@/services/home'
import type { BannerItem } from '@/types/home'
import {http} from '@/utlis/http.ts'
const scrollTap = (e)=>{
  // console.log(e.detail);
  // console.log(e.detail.scrollHeight-e.detail.scrollTop);
  if(e.detail.scrollHeight-e.detail.scrollTop<800)onScrolltolowers();
}
const text=ref({
//   id:2,
//   text:'uni-app 版正式发布，开发一次，同时发布iOS、Android、H5、微信小程序、支付宝小程序、百度小程序、头条小程序等7大平台。'
})
let img_list=ref(null)
const skeletonflag = ref(false)
uni.request({
  url: 'advertising/',
  data: {},
  header: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
    'X-Requested-With': 'XMLHttpRequest'
  },
  method: 'GET',
  sslVerify: true,
  success: ({ data, statusCode, header }) => {
    console.log('index:',data)
    img_list.value=data.img_list
    text.value=data.text
    skeletonflag.value = false
 
  },
  fail: (error) => {
    return 'error'
  }
})
const guessList = ref(false)
const onScrolltolowers = ()=>{
        if(pageParam.value.page_num<pageParam.value.page_count){
            pageParam.value.page_num++
            uni.request({
  url: 'comment/matron/hot/',
  data: pageParam.value,
  header: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
    'X-Requested-With': 'XMLHttpRequest'
  },
  method: 'POST',
  success: ({ data, statusCode, header }) => {
    guessList.value.push(...data.list)
    pageParam.value.page_count = data.count
    // console.log('sgg',guessList.value)
  },
  fail: (error) => {}
 })
  
        }
        else{
          
        }
  }
  const pageParam=ref({
    page_num:1,
    page_size:10,
    page_count:0 
  })
 uni.request({
  url: 'comment/matron/hot/',
  data: pageParam.value,
  header: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
    'X-Requested-With': 'XMLHttpRequest'
  },
  method: 'POST',
  success: ({ data, statusCode, header }) => {
    guessList.value=data.list
    pageParam.value.page_count = data.count
    // console.log('gg',data)
  },
  fail: (error) => {}
 })
  
</script>
<template>
  <!-- 导航栏/搜索框 -->
  <customNavigate />
 
 <scroll-view 
 class="scroll-view"
 scroll-y
 @scroll="scrollTap"
 >
 <Pageskeleton v-if="skeletonflag"></Pageskeleton>
<template v-else>
    <!-- 公告栏 -->
    <noticeBar
    show-icon scrollable
    :text="text.text"
     ></noticeBar>
  
<!-- 轮播图 -->
<customSwiper style="margin: 0;margin-bottom: -10px;" :img_list="img_list" ></customSwiper>
<!-- 六宫格 -->
<myselect style="display: block;"></myselect>
  <!-- 妈咪好评论榜 -->
<mydell :guessList="guessList" :pageParam="pageParam"></mydell>
</template>
</scroll-view>
</template>
<style lang="scss">


page {
  background-color: #f7f7f7;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.scroll-view {
  flex: 1;
  height: 80%;
}
</style>
